﻿@COFE ?= {}

$ = jQuery
Entry = COFE.Entry
utils = COFE.utils

# CONTROLLER - Represents one entry.
#     params - @el, @templateKey (css template) , @entry (entry model), @App (for calling methods like changePath())
#     events - clicked
class EntryItem extends Spine.Controller
  constructor : () ->                   # Overridable parameters.
    @folderClicked = "changePath"       # valid options (none, changePath / changeSelection)  
    @fileClicked = "changeSelection"    # valid options (none, changeSelection)
    super        
    
  elements :
    ".workIndicator" : "workIndicator"
    ".label" : "label"

  events :
    "click .changePath" : "click"
    
  init: ->     

  render: =>    
    @el.html(@template(@entry))      
  
  remove: =>
    @el.remove()

  template: ->
    $(@templateKey).tmpl(@entry)
  
  click: ->
    # console.log "clicked" + @entry.path
    @trigger("clicked", @)
   

COFE.EntryItem = EntryItem